package com.va.yahooweather.commons;

import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.message.BasicNameValuePair;

public class HttpPostBuilder {
    private String uri;
    private List<NameValuePair> params;

    public HttpPostBuilder()
    {
        uri= "";
        params = new ArrayList<NameValuePair>();
    }
    
    public void setMainURI(String url) {
        this.uri = url;
    }
    
    public void putParam(String name, String value) {
        params.add(new BasicNameValuePair(name, value));
    }
    
    public HttpPost encodedHttpPost() throws UnsupportedEncodingException {
        HttpPost post = new HttpPost(uri);
        post.setEntity(new UrlEncodedFormEntity(params));
        
        return post;
    }
    
}
